package com.javatest.springbootamqp.service;

import com.javatest.springbootamqp.bean.Book;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

/**
 * @author lzy
 * @version v1.0 Create DateTime: 2019/4/23 16:21
 */
@Slf4j
@Service
public class BookService {

  @RabbitListener(queues = "atguigu.news")
  public void receive(Book book) {
    System.out.println("收到消息: " + book);
  }

  @RabbitListener(queues = "atguigu")
  public void receive02(Message message) {
    log.info("message body: " + message.getBody());
    log.info("message head:" + message.getMessageProperties());
  }
}
